<template>
	<view class="live-body">
		<!-- 头部 -->
		<trade-head title="直播间"></trade-head>
		<!--  -->
		<view class="body-view">
			<!-- 使用scroll-view实现tabs滑动切换 -->
			<scroll-view class="top-menu-view" scroll-x="true" :scroll-into-view="tabCurrent">
				<view class="menu-topic-view" v-for="item in tabs" :id="'tabNum'+item.id" :key="(item.id - 1)"
					@click="swichMenu(item.id - 1)">
					<view :class="currentTab==(item.id - 1) ? 'menu-topic-act' : 'menu-topic'">
						<text class="menu-topic-text">{{item.name}}</text>
						<view class="menu-topic-bottom">
							<view class="menu-topic-bottom-color"></view>
						</view>
					</view>
				</view>
			</scroll-view>
			<!-- 内容 -->
			<swiper class="swiper-box-list" :current="currentTab" @change="swiperChange">
				<!-- 预告直播 -->
				<swiper-item class="swiper-topic-list">
					<!-- 没有直播 -->
					<view class="live-null" v-if="!isLive">
						<view class="">
							<image src="../../static/live/live.png" mode="aspectFit"></image>
							<text>小主，暂时还没有直播预告哦</text>
						</view>
					</view>

					<!--有直播 -->
					<view class="liveing" v-else>
						<navigator :url="'/my-bus/live-details/live-details?id=' + item.id" class="liveing-content"
							style="background-image: url(https://img.js.design/assets/smartFill/img309164da746310.jpg); background-size: 200px;"
							v-for="(item, index) in shuju" :key="item.id">
							<view class="tag-view" v-if="item.islive">
								<image src="../../static/live/moon.png"></image>
								直播预告
							</view>
							<view class="tag-view" style="background: linear-gradient(180deg, #BEE700 0%, #8ACA00 100%);
		" v-else>
								<image src="../../static/live/Shape.png" style="background-color: #8ab100;"></image>
								正在直播
							</view>
							<view class="desc">
								Hello <text>贰月</text>
								<view>9-23 14:00开始直播</view>
							</view>
						</navigator>
					</view>
				</swiper-item>

				<!-- 正在直播 -->
				<swiper-item class="swiper-topic-list">
					<view class="liveing">
						<navigator class="liveing-content"
							style="background-image: url(https://img.js.design/assets/smartFill/img309164da746310.jpg); background-size: 200px;"
							v-for="(item, index) in shuju" :key="item.id" v-if="!item.islive">
							<view class="tag-view" v-if="item.islive">
								<image src="../../static/live/moon.png"></image>
								直播预告
							</view>
							<view class="tag-view" style="background: linear-gradient(180deg, #BEE700 0%, #8ACA00 100%);
					" v-else>
								<image src="../../static/live/Shape.png" style="background-color: #8ab100;"></image>
								正在直播
							</view>
							<view class="desc">
								Hello <text>贰月</text>
								<view>9-23 14:00开始直播</view>
							</view>
						</navigator>
					</view>
				</swiper-item>

				<!-- 直播回放 -->
				<swiper-item class="swiper-topic-list">
					<view class="playback-content">
						<!-- 左侧列表 -->
						<scroll-view scroll-y="true" class="left">
							<view :class="catelistActive === index ? 'active' : ''" v-for="(item, index) in catelist"
								:key="item.id" @click="leftClick(index)">
								{{ item.listName }}
							</view>
						</scroll-view>
						<!-- 右侧主体内容 -->
						<scroll-view scroll-y="true" class="right">
							<view class="view-content">
								<text>直播标题</text>
								<view class="image">
									
								</view>
							</view>
						</scroll-view>
					</view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 是否直播
				isLive: false,
				tabs: [{
						id: 1,
						name: '预告直播'
					},
					{
						id: 2,
						name: '正在直播'
					},
					{
						id: 3,
						name: '直播回放'
					},
				],
				currentTab: 0,
				tabCurrent: 'tabNum1',
				// 假数据
				shuju: [{
					id: 1,
					title: 'Hello',
					mounth: '贰月',
					time: '9:23',
					islive: true,
					viewNumber: 100,
					img: 'https://img.js.design/assets/smartFill/img309164da746310.jpg'
				}, {
					id: 2,
					title: 'Hello',
					mounth: '贰月',
					time: '9:23',
					islive: false,
					viewNumber: 100,
					img: 'https://img.js.design/assets/smartFill/img309164da746310.jpg'
				}, {
					id: 3,
					title: 'Hello',
					mounth: '贰月',
					time: '9:23',
					islive: true,
					viewNumber: 100,
					img: 'https://img.js.design/assets/smartFill/img309164da746310.jpg'
				}, {
					id: 4,
					title: 'Hello',
					mounth: '贰月',
					time: '9:23',
					islive: false,
					viewNumber: 100,
					img: 'https://img.js.design/assets/smartFill/img309164da746310.jpg'
				}],
				// 当前设备可用的高度
				wh: 0,
				// 激活项
				active: 0,
				scrollTop: 0,
				// 左侧列表循环激活项
				catelistActive: 0,
				// 左侧列表数据
				catelist: [{
						id: 1,
						listName: '直播回放',
						children: [{
								id: 1,
								listName: '直播回访标题直播回访标题',
								imgSrc: 'https://img.js.design/assets/smartFill/img313164da746310.jpg'
							},
							{
								id: 2,
								listName: '回访标题直播回访标题',
								imgSrc: 'https://img.js.design/assets/smartFill/img313164da746310.jpg'
							},
							{
								id: 3,
								listName: '直播回访标题直播回访标题',
								imgSrc: 'https://img.js.design/assets/smartFill/img313164da746310.jpg'
							}
						]
					},
					{
						id: 2,
						listName: '直播回放',
						children: [{
								id: 1,
								listName: '直播回访标题直播回访标题',
								imgSrc: 'https://img.js.design/assets/smartFill/img313164da746310.jpg'
							},
							{
								id: 2,
								listName: '回访标题直播回访标题',
								imgSrc: 'https://img.js.design/assets/smartFill/img313164da746310.jpg'
							},
							{
								id: 3,
								listName: '直播回访标题直播回访标题',
								imgSrc: 'https://img.js.design/assets/smartFill/img313164da746310.jpg'
							}
						]
					},
					{
						id: 3,
						listName: '直播回放'
					},
					{
						id: 4,
						listName: '直播回放'
					}
				]
			}
		},
		onLoad() {
			const sysInfo = uni.getSystemInfoSync()
			this.wh = sysInfo.windowHeight - 50

			this.live()

			// this.getCateList()
		},
		methods: {
			leftClick(index) {
				this.catelistActive = index
			},
			// 判断是否有直播
			live() {
				if (this.shuju.length != 0) {
					this.isLive = true
				}
			},
			swichMenu(id) {
				this.currentTab = id
				this.tabCurrent = 'tabNum' + id
				console.log(id)
			},
			swiperChange(e) {
				let index = e.detail.current
				this.swichMenu(index)
			},
		}
	}
</script>

<style scoped lang="scss">
	.live-body {
		font-family: "思源黑体";
	}
	.body-view {
		height: 100vh;
		width: 100%;
		display: flex;
		flex: 1;
		flex-direction: column;
		overflow: hidden;
		align-items: flex-start;
		justify-content: center;
		// padding-top: 40px;

	}

	.head {
		width: 100%;
		height: 176rpx;
		background: linear-gradient(270deg, #FF653D 0%, #FF8800 100%);
		;
		// height: 40px !important;
	}

	.top-menu-view {
		display: flex;
		position: fixed;
		z-index: 997;
		top: 176rpx;
		left: 0;
		// white-space: nowrap;
		width: 100%;
		height: 86rpx;
		line-height: 86rpx;
		border-bottom: 2rpx solid rgba(238, 238, 238, 1);
		background-color: rgba(255, 255, 255, 1); // tab背景

		.menu-topic-view {
			display: inline-block;
			white-space: nowrap;
			// width: 112rpx;
			height: 86rpx;
			position: relative;
			margin-right: 136rpx;

			&:first-child {
				margin-left: 60rpx;
			}

			&:last-child {
				margin-right: 0;
			}


			.menu-topic-text {
				font-size: 30rpx;
				color: #303133;
			}

			// .menu-topic-act {
			// 	margin-left: 30upx;
			// 	margin-right: 10upx;
			// 	position: relative;
			// 	height: 100%;
			// 	display: flex;
			// 	align-items: center;
			// 	justify-content: center;
			// }

			.menu-topic-bottom {
				position: absolute;
				bottom: 0;
				width: 100%;

				.menu-topic-bottom-color {
					width: 100%;
					height: 4rpx;
				}
			}

			.menu-topic-act .menu-topic-bottom {
				display: flex;
				justify-content: center;
			}

			.menu-topic-act .menu-topic-bottom-color {
				background: rgba(255, 135, 2, 1);
				color: rgba(255, 135, 2, 1);
			}



		}


	}

	.swiper-box-list {
		width: 100%;
		// padding-top: 270rpx;
		flex: 1;
		background-color: rgba(250, 250, 250, 1);

		.swiper-topic-list {
			width: 100%;
			padding-top: 20rpx;

			// 没有直播
			.live-null {
				width: 100%;
				height: 100%;
				text-align: center;
				position: relative;


				view {
					width: 312rpx;
					height: 296rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					font-size: 12px;
					color: rgba(204, 204, 204, 1);
					margin-top: 100px;
					// position: absolute;
					// left: 50%;
					// top: 20%;
					// margin-left: -156rpx;

					image {
						width: 260rpx;
						margin-bottom: 7px;
					}

				}
			}

			// 有直播
			.liveing {
				width: 688rpx;
				height: 100%;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				align-content: flex-start;
				flex-wrap: wrap;
				align-items: center;
				margin: 0 auto;

				.liveing-content {
					width: 280rpx;
					height: 248rpx;
					border-radius: 10px;
					overflow: hidden;
					padding: 18rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					margin-bottom: 30rpx;
				}

				.tag-view {
					width: 70px;
					height: 30rpx;
					border-radius: 15rpx;
					display: flex;
					align-items: center;
					background: linear-gradient(235deg, rgba(255, 137, 96, 1) 0%, rgba(255, 98, 165, 1));
					font-size: 18rpx;
					color: rgba(255, 255, 255, 1);
					line-height: 15px;

					image {
						width: 22rpx;
						height: 22rpx;
						margin-left: 4px;
						margin-right: 4px;
						border-radius: 50%;
					}
				}

				.desc {
					display: flex;
					justify-content: space-between;
					align-items: center;
					color: rgba(255, 255, 255, 1);
					font-size: 23rpx;

					text {
						margin-left: 10rpx;
					}

					view {
						width: 140rpx;
						height: 30rpx;
						font-size: 14rpx;
						background: null;
						border-radius: 100rpx;
						line-height: 30rpx;
						text-align: center;
						margin-left: 28rpx;
						border: 2rpx solid #acacac;
					}
				}
			}

			.scroll-view-container {
				width: 100%;
				height: 100%;
				display: flex;

				.left {
					width: 200rpx;
					height: 100%;
					background-color: #f7f6fb;

					view {
						width: 100%;
						height: 64rpx;
						text-align: center;
						line-height: 64rpx;
					}

					.active {
						background-color: #ffffff;
						// ::before {}
					}
				}

				.right {
					flex: 1;
					padding-left: 20rpx;
					font-size: 24rpx;

					text {}

					image {
						width: 480rpx;
						margin-top: -50rpx;
						margin-bottom: -50rpx;
					}
				}
			}
		}
	}

	// 有直播
	.liveing {
		width: 688rpx;
		height: 100%;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-content: flex-start;
		flex-wrap: wrap;
		align-items: center;
		margin: 0 auto;
		padding-top: 270rpx;

		.liveing-content {
			width: 280rpx;
			height: 248rpx;
			border-radius: 10px;
			overflow: hidden;
			padding: 18rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			margin-bottom: 30rpx;
		}

		.tag-view {
			width: 70px;
			height: 30rpx;
			border-radius: 15rpx;
			display: flex;
			align-items: center;
			background: linear-gradient(235deg, rgba(255, 137, 96, 1) 0%, rgba(255, 98, 165, 1));
			font-size: 18rpx;
			color: rgba(255, 255, 255, 1);
			line-height: 15px;

			image {
				width: 22rpx;
				height: 22rpx;
				margin-left: 4px;
				margin-right: 4px;
				border-radius: 50%;
			}
		}

		.desc {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: rgba(255, 255, 255, 1);
			font-size: 23rpx;

			text {
				margin-left: 10rpx;
			}

			view {
				width: 140rpx;
				height: 30rpx;
				font-size: 14rpx;
				background: null;
				border-radius: 100rpx;
				line-height: 30rpx;
				text-align: center;
				margin-left: 28rpx;
				border: 2rpx solid #acacac;
			}
		}
	}

	.playback-content {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: space-between;
		// padding-top: 270rpx;
		margin-top: 245rpx;

		.left {
			padding-top: 32rpx;
			width: 200rpx;
			height: 100%;
			background: #F7F6FB;

			view {
				width: 100%;
				height: 64rpx;
				text-align: center;
				line-height: 64rpx;
				font-size: 28rpx;
				position: relative;
			}

			.active {
				background: #FFFFFF;

				&::before {
					content: "";
					display: inline-block;
					width: 6rpx;
					height: 64rpx;
					position: absolute;
					left: 0;
					top: 0;
					border-radius: 0px 100px 100px 0px;
					background: #FF8800;
				}
			}

		}

		.right {
			flex: 1;
			padding-left: 20rpx;
			padding-top: 14rpx;

			.view-content {
				width: 480rpx;
				height: 290rpx;
				text {
					font-size: 24rpx;
				}

				.image {
					width: 480rpx;
					height: 240rpx;
					overflow: hidden;
					border-radius: 10rpx;
					background-image: url("https://img.js.design/assets/smartFill/img338164da748e08.jpg");
					background-position: center;
					background-size: 500rpx;
					image {
						width: 480rpx;
						height: 240rpx;
					}
				}
			}
		}
	}
</style>
